<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:useBean id="pos_new" scope="page" class="software.Pos_post"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>软件开发交流平台</title>
<style type="text/css">
#Div{width:1024px;
	height:627px;
	margin-left:auto;
	margin-right:auto;
	background:#FFF2CE;
	padding-top:0px;
	}
   #Div1{
	width:165px;
	height:627px;
	margin-left:0px;
	margin-top:0px;
	padding-top:0px;
	float: left;
	background:url(../images/hy/ft_01.jpg) no-repeat;
	padding-left: 0px;
	}
.wenbq {
	height: 502px;
	width: 666px;
}
	#Div2 {
	background-color: #FFF2CE;
	height: 627px;
	width:859px;
	float: right;
	padding-top:0px;
	float:right;
    }
	#Div3 {
	width:694px;
	height: 627px;
	background-color: #FFF2CE;
	float: left;
	padding-top:0px;
    }
    #Div4 {
	width:165px;
	height:627px;
	margin-right:0px;
	margin-top:0px;
	padding-top:0px;
	float:right;
	background-image: url(../images/hy/ft_02.jpg);
	background-repeat: no-repeat;
	padding-right: 0px;
	 }
	#Div5 {
		 width:41px;
		 height:23px;
	     padding-top:0px;
	     float:left;
    }
	#Div6 {
		 width:653px;
		 height:23px;
	     padding-top:0px;
	     float:right;
    }
.beij {
	background:#FFF;
}
.button1 {
	margin-left: 35px;
	margin-top:11px;
	height: 37px;
	width: 82px;
	background:url(../images/hy/ft_05.jpg);
	background-repeat: no-repeat;
	border:0px;
}
.button2 {
	margin-left: 22px;
	height: 37px;
	width: 82px;
	background-repeat: no-repeat;
	border:0px;
    background:url(../images/hy/ft_06.jpg);
}

#Div_11 {
	background-color: #FFF2CE;
	background-image: url(../images/hy/ft_25.jpg);
	background-repeat: no-repeat;
	height: 30px;
	width: 418px;
	float: left;
}
#Div_12 {
	background-color: #FFF2CE;
	background-image: url(../images/hy/ft_26.jpg);
	background-repeat: no-repeat;
	height: 30px;
	width: 276px;
	margin-top: 0px;
	float: right;
}
#Div_1 {
	height: 30px;
	width: 694px;
	margin-top: 0px;
	background:#F1B766;
}
.wenb{
	width:357px;
	height:22px;
	margin-left:58px;
	margin-top:4px;
	border:0px;
	}
.xuanz{
	width:69px;
	height:22px;
	margin-left:78px;
	margin-top:4px;
	}
.wenbq{
	margin-top:10px;
	margin-left:2px;
	width:656px;
	height:502px;
}
#Div_13
{
	background-color:#FFF2CE;
	}
</style>
<link rel="stylesheet" href="../kindeditor/plugins/code/prettify.css" />
	<script charset="utf-8" src="../kindeditor/kindeditor.js"></script>
	<script charset="utf-8" src="../kindeditor/kindeditor.js"></script>
	<script charset="utf-8" src="../kindeditor/lang/zh_CN.js"></script>
	<script charset="utf-8" src="../kindeditor/plugins/code/prettify.js"></script>
	<script>
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="content"]', {
				cssPath : '../kindeditor/plugins/code/prettify.css',
				uploadJson : '../kindeditor/jsp/upload_json.jsp',
				fileManagerJson : '../kindeditor/jsp/file_manager_json.jsp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						document.forms['example'].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						document.forms['example'].submit();
					});
				}
			});
			prettyPrint();
		});
	</script>
	<script type="text/javascript">
	function check(){
		if(form2.title.value==""){
			alert("请输入你的标题");
			form2.title.focus();
			return false;
		}
		else if(form2.content.value==""){
			alert("必须输入内容");
				form2.content.focus();
			return false;
		}
		else{
			return true;
		}
	}
	</script>
  </head>
  <body>
  <%
	request.setCharacterEncoding("UTF-8");
	String content = request.getParameter("content");
	String title=request.getParameter("title");
	int plates=0;
	try{plates=Integer.parseInt(request.getParameter("select"));}
	catch(Exception e){
		e.printStackTrace();
	}

	if(plates!=0){
		int ID=0;
		try{ID=(Integer)session.getAttribute("ID");}
			catch(Exception e){}
		if(ID==0){
			out.print("<script>alert('请登录后发帖！')</script>");
		}else{
		 	pos_new.setID_Plates(plates);
		  	pos_new.setTitle(title);
		  	pos_new.setContent(content);
		  	pos_new.setID_User(ID);
		  	pos_new.Pos_New();
			response.sendRedirect("post.jsp?id="+pos_new.getID_Post());
		}
	}
  %>
 	<jsp:include page="head.jsp" />
   <div id="Div">
    <div id="Div1"></div>
    <div id="Div2">
     <div id="Div3">
       <div ><img id="Div5" src="../images/hy/ft_03.jpg" width="41" height="23" />
        <img id="Div6" src="../images/hy/ft_18.jpg" width="653" height="23" />
       </div>
<div>
<form  name="form2" method="post" action="ft.jsp" onsubmit="return check()">
<table width="694" height="604" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="697" height="2" colspan="5"><img src="../images/hy/ft_21.jpg" width="697" height="2" /></td>
    </tr>
     <tr>
    <td width="14" height="604" rowspan="4" ></td>
   <td width="666" height="10" colspan="3"></td>
   <td width="14" height="10" class="youcb"></td>
  </tr>
  <tr>
    <td width="666" height="532" rowspan="2" valign="top" class="beij">
    <div id="Div_1">
      <div id="Div_11"><input name="title" type="text" class="wenb"></div>
      
      <div id="Div_12">
      <select name="select" class="xuanz">
      	  <%
        	int Num=pos_new.getNum_Plates();
			String htmlData=new String();
			for(int i=0;i<Num;i++){
        	pos_new.NextItem();
         %>
          <option value="<%=pos_new.getID_Pos_New_Plates()%>"><%=pos_new.getNam_Pos_New_Plates()%></option>
          <%} %>
      </select>
      </div>
      <div id="Div_13"><textarea name="content" class="wenbq"style="visibility:hidden;">
      
  		 <%=htmlspecialchars(htmlData)%>
      </textarea>
      </div>
    </div>
   </td>
     <td width="14" height="265" colspan="3" class="youcb"></td>
  </tr>
  <tr>
    <td width="14" height="267" colspan="3" class="youcb"></td>
    </tr>
   <tr>
    <td width="666" height="60">
     
      <input name="" type="submit" value="" class="button1"/>
      <input name="" type="reset" value=""  class="button2"/>
	</td>
      <td width="14"  height="67" colspan="3" class="youcb"></td>
  </tr>
</table>
    </form>
</div>
    </div>
       <div id="Div4"></div>
    </div>
</div>
 	<jsp:include page="footer.jsp" />
  </body>
</html>

<%!
	private String htmlspecialchars(String str) {
	str = str.replaceAll("&", "&amp;");
	str = str.replaceAll("<", "&lt;");
	str = str.replaceAll(">", "&gt;");
	str = str.replaceAll("\"", "&quot;");
	return str;
}
%>
